import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:gluz/app/data/auth_entity.dart';
import 'package:gluz/app_session.dart';
import '../data/area_entity.dart';
import '../utils/colors.dart';
import 'bottom_modal_sheet.dart';

/// 表单输入框组件
class FormInputField extends StatelessWidget {
  final String label;
  final String? placeholder;
  final bool isRequired;
  final TextEditingController? controller;
  final TextInputType? keyboardType;
  final int? maxLines;
  final bool readOnly;

  /// 输入框换新行
  final bool newLine;
  final Function(String)? onChanged;
  final String? Function(String?)? validator;

  const FormInputField({
    super.key,
    required this.label,
    this.placeholder,
    this.isRequired = false,
    this.controller,
    this.keyboardType,
    this.maxLines = 1,
    this.readOnly = false,
    this.newLine = false,
    this.onChanged,
    this.validator,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Row(
          children: [
            Text(
              label,
              style: const TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500,
                color: AppColors.color_333333,
              ),
            ),
            if (isRequired)
              const Text(
                '*',
                style: TextStyle(fontSize: 16, color: Colors.red),
              ),
            if (newLine || app.isLangRU()) const Spacer(),
            if (newLine == false && !app.isLangRU()) ...[
              const SizedBox(width: 10),
              Expanded(
                child: TextFormField(
                  controller: controller,
                  keyboardType: keyboardType,
                  maxLines: maxLines,
                  onChanged: onChanged,
                  validator: validator,
                  textAlign: TextAlign.right,
                  readOnly: readOnly,
                  decoration: InputDecoration(
                    hintText: placeholder?.tr ?? '请输入'.tr,
                    hintStyle: TextStyle(
                      color: AppColors.color_8C8C8C,
                      fontSize: 14,
                    ),
                    filled: true,
                    fillColor: Colors.white,
                    border: UnderlineInputBorder(borderSide: BorderSide.none),
                    enabledBorder: UnderlineInputBorder(
                      borderSide: BorderSide.none,
                    ),
                    focusedBorder: UnderlineInputBorder(
                      borderSide: BorderSide.none,
                    ),
                    contentPadding: const EdgeInsets.symmetric(
                      horizontal: 0,
                      vertical: 12,
                    ),
                  ),
                ),
              ),
            ],
          ],
        ),

        if (newLine || app.isLangRU())
          TextFormField(
            controller: controller,
            keyboardType: keyboardType,
            maxLines: maxLines,
            onChanged: onChanged,
            validator: validator,
            textAlign: TextAlign.left,
            readOnly: readOnly,
            decoration: InputDecoration(
              hintText: placeholder?.tr ?? '请输入'.tr,
              hintStyle: TextStyle(color: AppColors.color_8C8C8C, fontSize: 14),
              filled: true,
              fillColor: Colors.white,
              border: UnderlineInputBorder(borderSide: BorderSide.none),
              enabledBorder: UnderlineInputBorder(borderSide: BorderSide.none),
              focusedBorder: UnderlineInputBorder(borderSide: BorderSide.none),
              contentPadding: const EdgeInsets.symmetric(
                horizontal: 0,
                vertical: 12,
              ),
            ),
          ),

        Divider(color: AppColors.color_EEEEEE),
      ],
    );
  }
}

/// 表单输入框组件
class ChooseInputField extends StatelessWidget {
  final String label;
  final String? placeholder;
  final bool isRequired;
  final Function()? onTap;
  final String? values;

  const ChooseInputField({
    super.key,
    required this.label,
    this.placeholder = '请选择',
    this.isRequired = false,
    this.onTap,
    this.values,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          children: [
            Text(
              label,
              style: const TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500,
                color: AppColors.color_333333,
              ),
            ),
            if (isRequired)
              const Text(
                '*',
                style: TextStyle(fontSize: 16, color: Colors.red),
              ),
            const Spacer(),
          ],
        ),

        InkWell(
          onTap: onTap,
          child: Container(
            margin: const EdgeInsets.symmetric(vertical: 8),
            padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
            width: double.infinity,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(5),
              color: AppColors.color_F7F7F7,
            ),
            child: Row(
              children: [
                Expanded(
                  child: Text(
                    values?.isNotEmpty == true ? values! : placeholder!,
                    style: TextStyle(fontSize: 10),
                  ),
                ),
                const SizedBox(width: 5),
                Icon(
                  Icons.arrow_forward_ios_rounded,
                  size: 12,
                  color: AppColors.color_D8D8D8,
                ),
              ],
            ),
          ),
        ),
        Divider(color: AppColors.color_EEEEEE),
      ],
    );
  }
}

/// 单选按钮组件
class FormRadioGroup extends StatelessWidget {
  final String label;
  final bool isRequired;
  final List<String> options;
  final String? selectedValue;
  final Function(String) onChanged;

  const FormRadioGroup({
    super.key,
    required this.label,
    this.isRequired = false,
    required this.options,
    this.selectedValue,
    required this.onChanged,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Padding(
          padding: EdgeInsets.symmetric(vertical: 10),
          child: Column(
            children: [
              Row(
                children: [
                  Text(
                    label,
                    style: TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.w500,
                      color: AppColors.color_333333,
                    ),
                  ),
                  if (isRequired)
                    const Text(
                      '*',
                      style: TextStyle(fontSize: 16, color: Colors.red),
                    ),
                  Spacer(),
                  if (!app.isLangRU())
                  Row(
                    spacing: 10,
                    children: options.map((option) {
                      return InkWell(
                        onTap: () => onChanged(option),
                        child: Row(
                          children: [
                            Image.asset(
                              selectedValue == option
                                  ? 'assets/images/auth/auth_type_sel.png'
                                  : 'assets/images/auth/auth_type_nor.png',
                              width: 20,
                              height: 20,
                            ),
                            const SizedBox(width: 8),
                            Text(
                              option,
                              style: TextStyle(
                                fontSize: 14,
                                color: AppColors.color_333333,
                              ),
                            ),
                          ],
                        ),
                      );
                    }).toList(),
                  ),
                ],
              ),
              if (app.isLangRU())
                SizedBox(height: 5,),
              if (app.isLangRU())
                Row(
                  spacing: 10,
                  children: options.map((option) {
                    return InkWell(
                      onTap: () => onChanged(option),
                      child: Row(
                        children: [
                          Image.asset(
                            selectedValue == option
                                ? 'assets/images/auth/auth_type_sel.png'
                                : 'assets/images/auth/auth_type_nor.png',
                            width: 20,
                            height: 20,
                          ),
                          const SizedBox(width: 8),
                          Text(
                            option,
                            style: TextStyle(
                              fontSize: 14,
                              color: AppColors.color_333333,
                            ),
                          ),
                        ],
                      ),
                    );
                  }).toList(),
                ),
            ],
          ),
        ),
        Divider(color: AppColors.color_EEEEEE),
      ],
    );
  }
}

/// 头像上传组件
class AvatarUploadField extends StatelessWidget {
  final String label;
  final String? imagePath;
  final String defaultAssets;
  final VoidCallback onTap;

  const AvatarUploadField({
    super.key,
    required this.label,
    this.imagePath,
    required this.onTap,
    this.defaultAssets = 'assets/images/auth/auth_upload_image.png',
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Row(
          children: [
            Text(
              label,
              style: TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500,
                color: AppColors.color_333333,
              ),
            ),
            const Spacer(),
            InkWell(
              onTap: onTap,
              child: ClipRRect(
                borderRadius: BorderRadius.circular(24),
                child: imagePath?.isEmpty == true
                    ? Image.asset(
                        defaultAssets,
                        width: 48,
                        height: 48,
                        fit: BoxFit.cover,
                      )
                    : CachedNetworkImage(
                        width: 48,
                        height: 48,
                        imageUrl: imagePath!,
                        fit: BoxFit.cover,
                      ),
              ),
            ),
          ],
        ),
        Divider(color: AppColors.color_EEEEEE),
      ],
    );
  }
}

/// 图片上传组件
class ImageUploadFieldCircle extends StatelessWidget {
  final String label;
  final String imageTip;
  final String? defaultAssets;
  final String? imagePath;
  final VoidCallback onTap;
  final void Function(int) onDelete;

  const ImageUploadFieldCircle({
    super.key,
    required this.label,
    required this.imageTip,
    this.defaultAssets = 'assets/images/auth/auth_upload_image.png',
    this.imagePath,
    required this.onTap,
    required this.onDelete,
  });

  @override
  Widget build(BuildContext context) {
    List<String> images = [];
    if (imagePath?.isNotEmpty == true) {
      images = imagePath!.split(',');
    }
    return Column(
      children: [
        Row(
          children: [
            Text(
              label,
              style: TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500,
                color: AppColors.color_333333,
              ),
            ),
            const Spacer(),
            InkWell(
              onTap: onTap,
              child: ClipRRect(
                borderRadius: BorderRadius.circular(24),
                child: Image.asset(
                  defaultAssets!,
                  width: 48,
                  height: 48,
                  fit: BoxFit.cover,
                ),
              ),
            ),
          ],
        ),

        if (images.isNotEmpty)
          InkWell(
            onTap: onTap,
            child: SizedBox(
              height: 120,
              child: ListView.separated(
                padding: const EdgeInsets.symmetric(vertical: 10),
                scrollDirection: Axis.horizontal,
                itemCount: images.length,
                separatorBuilder: (ctx, index) {
                  return SizedBox(width: 5,);
                },
                itemBuilder: (ctx, index) {
                  return Stack(
                    children: [
                      ClipRRect(
                        borderRadius: BorderRadius.circular(8),
                        child: CachedNetworkImage(
                          imageUrl: images[index],
                          width: 130,
                          height: 100,
                          fit: BoxFit.cover,
                        ),
                      ),
                      Positioned(
                        right: 0,
                        top: 0,
                        child: InkWell(
                          onTap: () {
                            onDelete(index);
                          },
                          child: Icon(Icons.remove_circle_rounded, color: AppColors.color_8C8C8C,),
                        ),
                      )
                    ],
                  );
                },
              ),
            ),
          ),
        Divider(color: AppColors.color_EEEEEE),
      ],
    );
  }
}

/// 图片上传组件
class ImageUploadField extends StatelessWidget {
  final String label;
  final bool isRequired;
  final String? imagePath;
  final String? defaultAssets;
  final String placeholderText;
  final VoidCallback onTap;

  const ImageUploadField({
    super.key,
    required this.label,
    this.isRequired = false,
    this.imagePath,
    this.defaultAssets = 'assets/images/auth/auth_business.png',
    required this.placeholderText,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          children: [
            Text(
              label,
              style: const TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500,
                color: AppColors.color_333333,
              ),
            ),
            if (isRequired)
              const Text(
                '*',
                style: TextStyle(fontSize: 16, color: Colors.red),
              ),
          ],
        ),
        const SizedBox(height: 8),
        Text(
          '仅支持png, jpg格式; 大小不能超过3MB'.tr,
          style: TextStyle(fontSize: 12, color: AppColors.color_8C8C8C),
        ),
        const SizedBox(height: 8),
        InkWell(
          onTap: onTap,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ClipRRect(
                borderRadius: BorderRadius.circular(8),
                child: imagePath?.isEmpty == true
                    ? Image.asset(
                        defaultAssets!,
                        fit: BoxFit.cover,
                        width: 150,
                        height: 100,
                      )
                    : CachedNetworkImage(
                        imageUrl: imagePath!,
                        fit: BoxFit.fill,
                        width: 150,
                        height: 100,
                      ),
              ),
              const SizedBox(height: 8),
              Text(
                placeholderText,
                style: TextStyle(fontSize: 13, color: AppColors.color_8C8C8C),
              ),
            ],
          ),
        ),
        const SizedBox(height: 8),
      ],
    );
  }
}

/// 双图片上传组件（如身份证正反面）
class DualImageUploadField extends StatelessWidget {
  final String label;
  final String? frontImagePath;
  final String? backImagePath;
  final VoidCallback onFrontTap;
  final VoidCallback onBackTap;

  const DualImageUploadField({
    super.key,
    required this.label,
    this.frontImagePath,
    this.backImagePath,
    required this.onFrontTap,
    required this.onBackTap,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          label,
          style: TextStyle(
            fontSize: 16,
            fontWeight: FontWeight.w500,
            color: AppColors.color_333333,
          ),
        ),
        const SizedBox(height: 8),
        Text(
          '仅支持png, jpg格式; 大小不能超过3MB'.tr,
          style: TextStyle(fontSize: 12, color: AppColors.color_8C8C8C),
        ),
        const SizedBox(height: 8),
        Row(
          children: [
            Expanded(
              child: InkWell(
                onTap: onFrontTap,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    ClipRRect(
                      borderRadius: BorderRadius.circular(8),
                      child: frontImagePath?.isEmpty == true
                          ? Image.asset(
                              'assets/images/auth/auth_id_front.png',
                              fit: BoxFit.cover,
                            )
                          : CachedNetworkImage(
                              imageUrl: frontImagePath!,
                              width: double.infinity,
                              height: 100,
                              fit: BoxFit.fill,
                            ),
                    ),
                    const SizedBox(height: 4),
                    Text(
                      '点击上传身份证正面照'.tr,
                      style: TextStyle(
                        fontSize: 12,
                        color: AppColors.color_8C8C8C,
                      ),
                    ),
                  ],
                ),
              ),
            ),
            const SizedBox(width: 12),
            Expanded(
              child: InkWell(
                onTap: onBackTap,
                child: Container(
                  // height: 100,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      ClipRRect(
                        borderRadius: BorderRadius.circular(8),
                        child: backImagePath?.isEmpty == true
                            ? Image.asset(
                                'assets/images/auth/auth_id_back.png',
                                fit: BoxFit.cover,
                              )
                            : CachedNetworkImage(
                                imageUrl: backImagePath!,
                                width: double.infinity,
                                height: 100,
                                fit: BoxFit.fill,
                              ),
                      ),
                      const SizedBox(height: 4),
                      Text(
                        '点击上传身份证背面照'.tr,
                        style: TextStyle(
                          fontSize: 12,
                          color: AppColors.color_8C8C8C,
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ],
    );
  }
}

/// 圆形按钮上传组件
class CircleUploadButton extends StatelessWidget {
  final String label;
  final String? imagePath;
  final VoidCallback onTap;

  const CircleUploadButton({
    super.key,
    required this.label,
    this.imagePath,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      child: Container(
        width: 80,
        height: 80,
        decoration: BoxDecoration(
          color: AppColors.color_278AFF.withValues(alpha: 0.1),
          borderRadius: BorderRadius.circular(40),
          border: Border.all(color: AppColors.color_278AFF, width: 1),
        ),
        child: imagePath != null
            ? ClipRRect(
                borderRadius: BorderRadius.circular(40),
                child: Image.asset(imagePath!, fit: BoxFit.cover),
              )
            : Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Icon(
                    Icons.camera_alt,
                    color: AppColors.color_278AFF,
                    size: 24,
                  ),
                  const SizedBox(height: 4),
                  Text(
                    label,
                    style: TextStyle(
                      fontSize: 12,
                      color: AppColors.color_278AFF,
                    ),
                  ),
                ],
              ),
      ),
    );
  }
}

/// 选择器组件
class FormSelectorField extends StatelessWidget {
  final String label;
  final bool isRequired;
  final bool isShowDivider;
  final String? selectedValue;
  final String placeholder;
  final VoidCallback onTap;

  const FormSelectorField({
    super.key,
    required this.label,
    this.isRequired = false,
    this.selectedValue,
    required this.placeholder,
    required this.onTap,
    this.isShowDivider = true,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Row(
          children: [
            Text(
              label,
              style: TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500,
                color: AppColors.color_333333,
              ),
            ),
            if (isRequired)
              const Text(
                '*',
                style: TextStyle(fontSize: 16, color: Colors.red),
              ),
            Expanded(
              child: InkWell(
                onTap: onTap,
                child: Container(
                  padding: const EdgeInsets.symmetric(vertical: 12),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      Text(
                        selectedValue?.isNotEmpty == true ? selectedValue! : placeholder,
                        style: TextStyle(
                          fontSize: 14,
                          color: selectedValue?.isNotEmpty == true
                              ? AppColors.color_333333
                              : AppColors.color_8C8C8C,
                        ),
                      ),
                      const SizedBox(width: 8),
                      Icon(
                        Icons.arrow_forward_ios,
                        size: 16,
                        color: AppColors.color_8C8C8C,
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
        if (isShowDivider) Divider(color: AppColors.color_EEEEEE),
      ],
    );
  }
}

/// 标签选择组件
class TagSelectorField extends StatelessWidget {
  final String label;
  final bool isRequired;
  final List<String> options;
  final List<String> selectedOptions;
  final Function(String) onTagTap;

  const TagSelectorField({
    super.key,
    required this.label,
    this.isRequired = false,
    required this.options,
    required this.selectedOptions,
    required this.onTagTap,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          children: [
            Text(
              label,
              style: TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500,
                color: AppColors.color_333333,
              ),
            ),
            if (isRequired)
              const Text(
                '*',
                style: TextStyle(fontSize: 16, color: Colors.red),
              ),
          ],
        ),
        const SizedBox(height: 12),
        Wrap(
          spacing: 12,
          runSpacing: 8,
          children: options.map((option) {
            final isSelected = selectedOptions.contains(option);
            return InkWell(
              onTap: () => onTagTap(option),
              child: Container(
                padding: const EdgeInsets.symmetric(
                  horizontal: 16,
                  vertical: 8,
                ),
                decoration: BoxDecoration(
                  color: isSelected
                      ? AppColors.color_D7E9FF
                      : AppColors.color_F7F7F7,
                  borderRadius: BorderRadius.circular(20),
                  border: Border.all(
                    color: isSelected
                        ? AppColors.color_278AFF
                        : AppColors.color_F7F7F7,
                    width: 1,
                  ),
                ),
                child: Text(
                  option,
                  style: TextStyle(
                    fontSize: 14,
                    color: isSelected
                        ? AppColors.color_278AFF
                        : AppColors.color_333333,
                  ),
                ),
              ),
            );
          }).toList(),
        ),
        const SizedBox(height: 16),
        Divider(color: AppColors.color_EEEEEE),
      ],
    );
  }
}

/// 已选标签显示组件
class SelectedTagsField extends StatelessWidget {
  final String label;
  final bool isRequired;
  final List<String> selectedTags;
  final VoidCallback? onTap;
  final Function(String) onTagRemove;

  const SelectedTagsField({
    super.key,
    required this.selectedTags,
    required this.onTagRemove,
    required this.label,
    required this.isRequired,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          children: [
            Text(
              label,
              style: TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500,
                color: AppColors.color_333333,
              ),
            ),
            if (isRequired)
              const Text(
                '*',
                style: TextStyle(fontSize: 16, color: Colors.red),
              ),
            Expanded(
              child: InkWell(
                onTap: onTap,
                child: Container(
                  padding: const EdgeInsets.symmetric(vertical: 12),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      Text(
                        '请选择'.tr,
                        style: TextStyle(
                          fontSize: 14,
                          color: AppColors.color_8C8C8C,
                        ),
                      ),
                      const SizedBox(width: 8),
                      Icon(
                        Icons.arrow_forward_ios,
                        size: 16,
                        color: AppColors.color_8C8C8C,
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
        if (selectedTags.isNotEmpty) ...[
          Wrap(
            spacing: 8,
            runSpacing: 8,
            children: selectedTags.map((tag) {
              return FilledButton(
                style: FilledButton.styleFrom(
                  backgroundColor: AppColors.color_D7E9FF,
                  side: BorderSide(color: AppColors.color_278AFF, width: 1),
                ),
                onPressed: () {
                  onTagRemove(tag);
                },
                child: Text(
                  tag,
                  style: TextStyle(color: AppColors.color_278AFF),
                ),
              );
            }).toList(),
          ),
          const SizedBox(height: 16),
        ],
        Divider(color: AppColors.color_EEEEEE),
      ],
    );
  }
}

class RoadMapWidget extends StatelessWidget {
  List<TransportAgentTask>? roadMapList;
  final VoidCallback? onTapAdd;

  RoadMapWidget({super.key, this.roadMapList, required this.onTapAdd});

  @override
  Widget build(BuildContext context) {
    return StatefulBuilder(
      builder: (ctx, state) {
        return Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 10),
                  child: Text(
                    '经营线路'.tr,
                    style: TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.w500,
                      color: AppColors.color_333333,
                    ),
                  ),
                ),
              ],
            ),

            ListView.separated(
              physics: NeverScrollableScrollPhysics(), // 禁用滚动
              shrinkWrap: true,
              itemCount: roadMapList!.length,
              separatorBuilder: (ctx, index) {
                return SizedBox(height: 5,);
              },
              itemBuilder: (ctx, index) {
                TransportAgentTask roadMap = roadMapList![index];
                return Column(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    if (index > 0)
                      InkWell(
                        onTap: () {
                          roadMapList?.removeAt(index);
                          state((){});
                        },
                        child: Icon(Icons.highlight_remove, color: AppColors.color_8C8C8C,),
                      ),
                    Container(
                      padding: const EdgeInsets.symmetric(vertical: 10),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(13),
                        border: Border.all(color: AppColors.color_D8D8D8, width: 1),
                      ),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceAround,
                        children: [
                          InkWell(
                            onTap: () {
                              BottomModalSheet.showAreaSector((entity) {
                                roadMap.startPoint = entity.name;
                                state((){});
                              });
                            },
                            child: SizedBox(
                              width: 100,
                              child: Text(
                                textAlign: TextAlign.center,
                                roadMap.startPoint ?? '起点'.tr,
                                style: TextStyle(
                                  fontWeight: FontWeight.bold,
                                  fontSize: 18,
                                  color: roadMap.startPoint != null ? Colors.black : AppColors.color_8C8C8C,
                                ),
                              ),
                            ),
                          ),
                          InkWell(
                            onTap: () {
                              String? temp = roadMap.startPoint;
                              roadMap.startPoint = roadMap.endPoint;
                              roadMap.endPoint = temp;
                              state((){});
                            },
                            child: Image.asset(
                              'assets/images/auth/auth_map_exchange.png',
                              width: 40,
                              height: 40,
                            ),
                          ),
                          InkWell(
                            onTap: () {
                              BottomModalSheet.showAreaSector((entity) {
                                roadMap.endPoint = entity.name;
                                state((){});
                              });
                            },
                            child: SizedBox(
                              width: 100,
                              child: Text(
                                textAlign: TextAlign.center,
                                roadMap.endPoint ?? '终点'.tr,
                                style: TextStyle(
                                  fontWeight: FontWeight.bold,
                                  fontSize: 18,
                                  color: roadMap.endPoint != null ? Colors.black : AppColors.color_8C8C8C,
                                ),
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                );
              },
            ),

            Center(
              child: OutlinedButton.icon(
                style: OutlinedButton.styleFrom(
                  iconColor: AppColors.color_278AFF,
                  minimumSize: Size(30, 38),
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(19),
                  ),
                  side: BorderSide(width: 1, color: AppColors.color_278AFF),
                ),
                onPressed: onTapAdd,
                icon: Icon(Icons.add_circle_outline_rounded),
                label: Text(
                  '添加'.tr,
                  style: TextStyle(color: AppColors.color_278AFF),
                ),
              ),
            ),

            Divider(color: AppColors.color_EEEEEE),
          ],
        );
      },
    );
  }
}
